package com.open.system.controller;

import com.alibaba.fastjson.JSONObject;
import com.open.common.controller.BaseController;
import com.open.common.utils.PageUtils;
import com.open.common.utils.Query;
import com.open.common.utils.R;
import com.open.loan.domain.rsp.RspJuxinliHistoryDayModel;
import com.open.system.domain.LoanJuxinliReportDO;
import com.open.system.domain.LoanUserDO;
import com.open.system.service.LoanAdminLogService;
import com.open.system.service.LoanApplyLogService;
import com.open.system.service.LoanJuxinliReportService;
import com.open.system.service.LoanUserService;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 报告
 */
 
@Controller
@RequestMapping("/system/loanJuxinliReport")
public class LoanJuxinliReportController extends BaseController {
	@Autowired
	private LoanJuxinliReportService loanJuxinliReportService;
	
	@Autowired
	private LoanUserService userService;
	
	@Autowired
	private LoanApplyLogService loanApplyLogService;
	
	@Autowired
	private LoanAdminLogService loanAdminLogService;
	
	@GetMapping()
	@RequiresPermissions("system:loanJuxinliReport:loanJuxinliReport")
	String LoanJuxinliReport(){
	    return "system/loanJuxinliReport/loanJuxinliReport";
	}
	
	@ResponseBody
	@GetMapping("/list")
	@RequiresPermissions("system:loanJuxinliReport:loanJuxinliReport")
	public PageUtils list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);
		List<LoanJuxinliReportDO> loanJuxinliReportList = loanJuxinliReportService.list(query);
		int total = loanJuxinliReportService.count(query);
		PageUtils pageUtils = new PageUtils(loanJuxinliReportList, total);
		return pageUtils;
	}
	
	@GetMapping("/add")
	@RequiresPermissions("system:loanJuxinliReport:add")
	String add(){
	    return "system/loanJuxinliReport/add";
	}

	@GetMapping("/edit/{id}")
	@RequiresPermissions("system:loanJuxinliReport:edit")
	String edit(@PathVariable("id") Long id,Model model){
		LoanJuxinliReportDO loanJuxinliReport = loanJuxinliReportService.get(id);
		model.addAttribute("loanJuxinliReport", loanJuxinliReport);
	    return "system/loanJuxinliReport/edit";
	}
	
	
	@GetMapping("/honeyJar/{id}")
	@RequiresPermissions("system:loanJuxinliReport:honeyJar")
	public String honeyJar(@PathVariable("id") Long id, Model model, HttpServletRequest request) {
		LoanUserDO user=userService.get(id);
		model.addAttribute("user", user);
		Map<String,Object>map=new HashMap<String,Object>();
		map.put("userId", id);
		List<LoanJuxinliReportDO>reportLists= loanJuxinliReportService.list(map);
		if(reportLists!=null && reportLists.size()>0){
			LoanJuxinliReportDO reportDo=reportLists.get(0);
			
			//--操作日志--开始--
			String shopId=getUser().getEmail();
			String adminName=getUser().getName();
			String Module="蜜罐报告";
			String detail="查看了【"+reportDo.getRealName()+"】的蜜罐报告";
			loanAdminLogService.saveLog(shopId, adminName, Module, detail);
			//--操作日志--结束--
			
			String iou_statistic=reportDo.getIouStatistic();//用户手机号借条信息
			JSONObject iouJson =JSONObject.parseObject(iou_statistic);
			String iou1=String.valueOf(iouJson.get("total_loan_times"));
			String iou2=String.valueOf(iouJson.get("total_loan_amount"));
			String iou3=String.valueOf(iouJson.get("recent_iou_status"));
			String iou4=String.valueOf(iouJson.get("recent_loan_time"));
			String iou5=String.valueOf(iouJson.get("recent_pay_back_time"));
			String iou6=String.valueOf(iouJson.get("in_repayment_times"));
			String iou7=String.valueOf(iouJson.get("in_repayment_amount"));
			String iou8=String.valueOf(iouJson.get("in_repayment_interest"));
			String iou9=String.valueOf(iouJson.get("overdue_payment_times"));
			String iou10=String.valueOf(iouJson.get("overdue_payment_amount"));
			String iou11=String.valueOf(iouJson.get("overdue_payment_interest"));
			String iou12=String.valueOf(iouJson.get("overdue_times"));
			String iou13=String.valueOf(iouJson.get("overdue_amount"));
			String iou14=String.valueOf(iouJson.get("overdue_interest"));
			String iou15=String.valueOf(iouJson.get("d360_iou_platform_cnt"));
			String iou16=String.valueOf(iouJson.get("d90_iou_platform_cnt"));
			String iou17=String.valueOf(iouJson.get("d30_iou_platform_cnt"));
			String iou18=String.valueOf(iouJson.get("d360_iou_query_times"));
			String iou19=String.valueOf(iouJson.get("d90_iou_query_times"));
			String iou20=String.valueOf(iouJson.get("d30_iou_query_times"));
			model.addAttribute("iou1", iou1);model.addAttribute("iou2", iou2);model.addAttribute("iou3", iou3);
			model.addAttribute("iou4", iou4);model.addAttribute("iou5", iou5);model.addAttribute("iou6", iou6);
			model.addAttribute("iou7", iou7);model.addAttribute("iou8", iou8);model.addAttribute("iou9", iou9);
			model.addAttribute("iou10", iou10);model.addAttribute("iou11", iou11);model.addAttribute("iou12", iou12);
			model.addAttribute("iou13", iou13);model.addAttribute("iou14", iou14);model.addAttribute("iou15", iou15);
			model.addAttribute("iou16", iou16);model.addAttribute("iou17", iou17);model.addAttribute("iou18", iou18);
			model.addAttribute("iou19", iou19);model.addAttribute("iou20", iou20);
			//====================================================
			String user_searched_statistic=reportDo.getUserSearchedStatistic();//被机构查询数量统计(去重后)
			JSONObject user_searched_statisticJson =JSONObject.parseObject(user_searched_statistic);
			String iou21=String.valueOf(user_searched_statisticJson.get("searched_org_cnt"));
			model.addAttribute("iou21", iou21);
			//====================================================
			String user_register_orgs=reportDo.getUserRegisterOrgs();//用户注册信息情况
			JSONObject user_register_orgsJson =JSONObject.parseObject(user_register_orgs);
			String reg1=String.valueOf(user_register_orgsJson.get("register_cnt"));
			String reg2=String.valueOf(user_register_orgsJson.get("phone_num"));
			String reg3=String.valueOf(user_register_orgsJson.get("register_orgs_statistics"));
			StringBuffer buffer=new StringBuffer();
			JSONArray reg3Arrays = JSONArray.fromObject(reg3);
			for (int j = 0; j < reg3Arrays.size(); j++) {
				 net.sf.json.JSONObject info = reg3Arrays.getJSONObject(j);
				 String str3="【"+info.get("label")+"-统计："+info.get("count")+"】<br/>";
				 buffer.append(str3);
			}
			model.addAttribute("reg1", reg1);model.addAttribute("reg2", reg2);
			model.addAttribute("buffer", buffer);
			//====================================================
			String user_blacklist=reportDo.getUserBlacklist();//黑名单信息
			JSONObject user_blacklistJson =JSONObject.parseObject(user_blacklist);
			String back1=String.valueOf(user_blacklistJson.get("blacklist_name_with_phone"));
			String back2=String.valueOf(user_blacklistJson.get("blacklist_name_with_idcard"));
			String back3=String.valueOf(user_blacklistJson.get("blacklist_category"));
			String back4=String.valueOf(user_blacklistJson.get("blacklist_details"));
			String [] back4Arr=back4.split(","); 
			StringBuffer backBuffer=new StringBuffer();
			for (int i = 0; i < back4Arr.length; i++) {
				String str=back4Arr[i];
				if(str.length()>0){
					if(!"[]".equals(str)){
						JSONObject strJson =JSONObject.parseObject(str);
						String str3=strJson.get("details_key")+"-"+strJson.get("details_value")+"/";
						backBuffer.append(str3);
					}
				}
			}
			String back5=String.valueOf(user_blacklistJson.get("blacklist_update_time_name_phone"));
			String back6=String.valueOf(user_blacklistJson.get("blacklist_update_time_name_idcard"));
			model.addAttribute("back1", back1=="false"?"否":"是");model.addAttribute("back2", back2=="false"?"否":"是");model.addAttribute("back3", back3);
			model.addAttribute("back4", backBuffer);model.addAttribute("back5", back5);model.addAttribute("back6", back6);
			//========================================================
			String user_basic=reportDo.getUserBasic();//基本信息
			JSONObject user_basicJson =JSONObject.parseObject(user_basic);
			String basic1=String.valueOf(user_basicJson.get("user_idcard"));
			String basic2=String.valueOf(user_basicJson.get("user_phone"));
			String basic3=String.valueOf(user_basicJson.get("user_idcard_valid"));
			String basic4=String.valueOf(user_basicJson.get("user_name"));
			String basic5=String.valueOf(user_basicJson.get("user_gender"));
			String basic6=String.valueOf(user_basicJson.get("user_age"));
			String basic7=String.valueOf(user_basicJson.get("user_phone_operator"));
			model.addAttribute("basic1", basic1);model.addAttribute("basic2", basic2);
			model.addAttribute("basic3", basic3=="false"?"否":"是");model.addAttribute("basic4", basic4);
			model.addAttribute("basic5", basic5);model.addAttribute("basic6", basic6);
			model.addAttribute("basic7", basic7);
			//========================================================
			String consumer_label=reportDo.getConsumerLabel();//消费标签信息
			JSONObject consumer_labelJson =JSONObject.parseObject(consumer_label);
			String labe1=String.valueOf(consumer_labelJson.get("if_own_cc"));
			String labe2=String.valueOf(consumer_labelJson.get("if_own_wg_cc"));
			String labe3=String.valueOf(consumer_labelJson.get("if_own_car"));
			String labe4=String.valueOf(consumer_labelJson.get("if_pay_ins"));
			String labe5=String.valueOf(consumer_labelJson.get("if_fin_buy_pre6"));
			String labe6=String.valueOf(consumer_labelJson.get("cst_score_finally"));
			model.addAttribute("labe1", labe1=="null"?"无":labe1);model.addAttribute("labe2", labe2=="null"?"无":labe2);
			model.addAttribute("labe3", labe3=="null"?"无":labe3);model.addAttribute("labe4", labe4=="null"?"无":labe4);
			model.addAttribute("labe5", labe5=="null"?"无":labe5);model.addAttribute("labe6", labe6=="null"?"无":labe6);
			//========================================================
			String user_gray=reportDo.getUserGray();//用户灰度分数信息
			JSONObject user_grayJson =JSONObject.parseObject(user_gray);
			String gray1=String.valueOf(user_grayJson.get("recent_active_time"));
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			if(StringUtils.isNotEmpty(gray1) && gray1!="null"){
				Date date = new Date(Long.parseLong(gray1));
				gray1=sdf.format(date);//最近活跃时间;
			}
			String gray2=String.valueOf(user_grayJson.get("phone_gray_score"));//灰度分
			String gray3=String.valueOf(user_grayJson.get("has_report"));//是否成功产生过蜜蜂报告
			String gray4=String.valueOf(user_grayJson.get("social_liveness"));//社交活跃度
			String gray5=String.valueOf(user_grayJson.get("social_influence"));//社交影响力
			model.addAttribute("gray1",gray1);model.addAttribute("gray2",gray2);
			model.addAttribute("gray3",gray3);model.addAttribute("gray4",gray4);
			model.addAttribute("gray5",gray5);
			//====================================================
			String user_gray_contacts_number_statistic=reportDo.getUserGrayContactsNumberStatistic();//联系人数相关字段
			JSONObject user_grayNumJson =JSONObject.parseObject(user_gray_contacts_number_statistic);
			String grayNum1=String.valueOf(user_grayNumJson.get("cnt_to_all"));//主动联系人数
			String grayNum2=String.valueOf(user_grayNumJson.get("cnt_be_all"));//被动联系人数
			String grayNum3=String.valueOf(user_grayNumJson.get("cnt_all"));//联系总人数
			String grayNum4=String.valueOf(user_grayNumJson.get("cnt_router"));//与黑号有联系的人数
			String grayNum5=String.valueOf(user_grayNumJson.get("cnt_to_black"));//主动联系的黑号数
			String grayNum6=String.valueOf(user_grayNumJson.get("cnt_be_black"));//被动联系的黑号数
			String grayNum7=String.valueOf(user_grayNumJson.get("cnt_black"));//黑号总数
			String grayNum8=String.valueOf(user_grayNumJson.get("cnt_to_applied"));//主动联系人中曾为申请人的人数
			String grayNum9=String.valueOf(user_grayNumJson.get("cnt_be_applied"));//被动联系人中曾为申请人的人数
			String grayNum10=String.valueOf(user_grayNumJson.get("pct_cnt_to_all"));//主动联系人群体中的百分位
			String grayNum11=String.valueOf(user_grayNumJson.get("pct_cnt_be_all"));//被动联系人群体中的百分位
			String grayNum12=String.valueOf(user_grayNumJson.get("pct_cnt_to_black"));//主动联系黑号群体中的百分位
			String grayNum13=String.valueOf(user_grayNumJson.get("pct_cnt_be_black"));//被动联系黑号群体中的百分位
			model.addAttribute("grayNum1",grayNum1);model.addAttribute("grayNum2",grayNum2);
			model.addAttribute("grayNum3",grayNum3);model.addAttribute("grayNum4",grayNum4);
			model.addAttribute("grayNum5",grayNum5);model.addAttribute("grayNum6",grayNum6);
			model.addAttribute("grayNum7",grayNum7);model.addAttribute("grayNum8",grayNum8);
			model.addAttribute("grayNum9",grayNum9);model.addAttribute("grayNum10",grayNum10);
			model.addAttribute("grayNum11",grayNum11);model.addAttribute("grayNum12",grayNum12);
			model.addAttribute("grayNum13",grayNum13);
			//======================================================================
			String user_gray_contacts_rfm=reportDo.getUserGrayContactsRfm();//联系权重R、F、M相关字段(rfm)
			JSONObject user_grayRfmJson =JSONObject.parseObject(user_gray_contacts_rfm);
			String rfm1=String.valueOf(user_grayRfmJson.get("recent_time_to_all"));//与所有联系人的最近主动通话时间，时间戳(ms)
			String rfm2=String.valueOf(user_grayRfmJson.get("recent_time_be_all"));//与所有联系人的最近被动通话时间，时间戳(ms)
			String rfm3=String.valueOf(user_grayRfmJson.get("recent_time_to_black"));//与黑号的最近主动通话时间，时间戳(ms)
			String rfm4=String.valueOf(user_grayRfmJson.get("recent_time_be_black"));//与黑号的最近被动通话时间，时间戳(ms)
			String rfm5=String.valueOf(user_grayRfmJson.get("recent_time_to_applied"));//与申请人的最近主动通话时间，时间戳(ms)
			String rfm6=String.valueOf(user_grayRfmJson.get("recent_time_be_applied"));//与申请人的最近被动通话时间，时间戳(ms)
			String rfm7=String.valueOf(user_grayRfmJson.get("call_cnt_to_all"));//与所有联系人的主动总通话次数
			String rfm8=String.valueOf(user_grayRfmJson.get("call_cnt_be_all"));//与所有联系人的被动总通话次数
			String rfm9=String.valueOf(user_grayRfmJson.get("call_cnt_to_black"));//与黑号的主动总通话次数
			String rfm10=String.valueOf(user_grayRfmJson.get("call_cnt_be_black"));//与黑号的被动总通话次数
			String rfm11=String.valueOf(user_grayRfmJson.get("call_cnt_to_applied"));//与申请人的主动通话次数
			String rfm12=String.valueOf(user_grayRfmJson.get("call_cnt_be_applied"));//与申请人的被动通话次数
			String rfm13=String.valueOf(user_grayRfmJson.get("time_spent_to_all"));//与所有联系人的主动总通话时长(s)
			String rfm14=String.valueOf(user_grayRfmJson.get("time_spent_be_all"));//与所有联系人的被动总通话时长(s)
			String rfm15=String.valueOf(user_grayRfmJson.get("time_spent_to_black"));//与黑号的主动总通话时长(s)
			String rfm16=String.valueOf(user_grayRfmJson.get("time_spent_be_black"));//与黑号的被动总通话时长(s)
			String rfm17=String.valueOf(user_grayRfmJson.get("time_spent_to_applied"));//与申请人的主动通话时长(s)
			String rfm18=String.valueOf(user_grayRfmJson.get("time_spent_be_applied"));//与申请人的被动通话时长(s)
			model.addAttribute("rfm1",rfm1);model.addAttribute("rfm2",rfm2);model.addAttribute("rfm3",rfm3);
			model.addAttribute("rfm4",rfm4);model.addAttribute("rfm5",rfm5);model.addAttribute("rfm6",rfm6);
			model.addAttribute("rfm7",rfm7);model.addAttribute("rfm8",rfm8);model.addAttribute("rfm9",rfm9);
			model.addAttribute("rfm10",rfm10);model.addAttribute("rfm11",rfm11);model.addAttribute("rfm12",rfm12);
			model.addAttribute("rfm13",rfm13);model.addAttribute("rfm14",rfm14);model.addAttribute("rfm15",rfm15);
			model.addAttribute("rfm16",rfm16);model.addAttribute("rfm17",rfm17);model.addAttribute("rfm18",rfm18);
			//===============================================================================
			String user_gray_contacts_closest=reportDo.getUserGrayContactsClosest();//与联系人最大亲密度
			JSONObject user_grayclosestJson =JSONObject.parseObject(user_gray_contacts_closest);
			String closest1=String.valueOf(user_grayclosestJson.get("weight_to_all"));//与所有联系人的最大主动联系亲密度,取值(0, 100)
			String closest2=String.valueOf(user_grayclosestJson.get("weight_be_all"));//与所有联系人的最大被动联系亲密度,取值(0, 100)
			String closest3=String.valueOf(user_grayclosestJson.get("weight_all"));//与所有联系人的最大互动联系亲密度，主被动亲密度相加，取值(0, 200)
			String closest4=String.valueOf(user_grayclosestJson.get("weight_to_black"));//与黑号的最大主动联系亲密度，取值(0, 100)
			String closest5=String.valueOf(user_grayclosestJson.get("weight_be_black"));//与黑号的最大被动联系亲密度，取值(0, 100)
			String closest6=String.valueOf(user_grayclosestJson.get("weight_black"));//与黑号的最大互动联系亲密度，主被动亲密度相加，取值(0, 200)
			String closest7=String.valueOf(user_grayclosestJson.get("weight_to_applied"));//与申请人的最大主动联系亲密度，取值(0, 100)
			String closest8=String.valueOf(user_grayclosestJson.get("weight_be_applied"));//与申请人的最大被动联系亲密度，取值(0, 100)
			String closest9=String.valueOf(user_grayclosestJson.get("weight_applied"));//与申请人的最大互动联系亲密度，主被动亲密度相加，取值(0, 200)
			model.addAttribute("closest1",closest1);model.addAttribute("closest2",closest2);
			model.addAttribute("closest3",closest3);model.addAttribute("closest4",closest4);
			model.addAttribute("closest5",closest5);model.addAttribute("closest6",closest6);
			model.addAttribute("closest7",closest7);model.addAttribute("closest8",closest8);
			model.addAttribute("closest9",closest9);
			//===============================================================================
			String user_gray_contacts_gray_score=reportDo.getUserGrayContactsGrayScore();//联系人灰色分信息
			JSONObject user_grayScoreJson =JSONObject.parseObject(user_gray_contacts_gray_score);
			String grayscore1=String.valueOf(user_grayScoreJson.get("most_familiar_to_all"));//主动联系最亲密联系人的灰度分
			String grayscore2=String.valueOf(user_grayScoreJson.get("most_familiar_be_all"));//被动联系最亲密联系人的灰度分
			String grayscore3=String.valueOf(user_grayScoreJson.get("most_familiar_all"));//互动联系最亲密联系人的灰度分
			String grayscore4=String.valueOf(user_grayScoreJson.get("most_familiar_to_applied"));//主动联系最亲密申请人的灰度分
			String grayscore5=String.valueOf(user_grayScoreJson.get("most_familiar_be_applied"));//被动联系最亲密申请人的灰度分
			String grayscore6=String.valueOf(user_grayScoreJson.get("most_familiar_applied"));//互动联系最亲密申请人的灰度分
			String grayscore7=String.valueOf(user_grayScoreJson.get("to_max"));//主动联系的联系人的最高灰度分
			String grayscore8=String.valueOf(user_grayScoreJson.get("to_mean"));//主动联系的联系人的平均灰度分
			String grayscore9=String.valueOf(user_grayScoreJson.get("to_min"));//主动联系的联系人的最低灰度分
			String grayscore10=String.valueOf(user_grayScoreJson.get("be_max"));//被动联系的联系人的最高灰度分
			String grayscore11=String.valueOf(user_grayScoreJson.get("be_mean"));//被动联系的联系人的平均灰度分
			String grayscore12=String.valueOf(user_grayScoreJson.get("be_min"));//被动联系的联系人的最低灰度分
			String grayscore13=String.valueOf(user_grayScoreJson.get("max"));//联系人的最高灰度分
			String grayscore14=String.valueOf(user_grayScoreJson.get("mean"));//联系人的平均灰度分
			String grayscore15=String.valueOf(user_grayScoreJson.get("min"));//联系人的最低灰度分
			model.addAttribute("grayscore1",grayscore1);model.addAttribute("grayscore2",grayscore2);
			model.addAttribute("grayscore3",grayscore3);model.addAttribute("grayscore4",grayscore4);
			model.addAttribute("grayscore5",grayscore5);model.addAttribute("grayscore6",grayscore6);
			model.addAttribute("grayscore7",grayscore7);model.addAttribute("grayscore8",grayscore8);
			model.addAttribute("grayscore9",grayscore9);model.addAttribute("grayscore10",grayscore10);
			model.addAttribute("grayscore11",grayscore11);model.addAttribute("grayscore12",grayscore12);
			model.addAttribute("grayscore13",grayscore13);model.addAttribute("grayscore14",grayscore14);
			model.addAttribute("grayscore15",grayscore15);

			//====================================================================================
			String user_gray_contacts_relation_distribution=reportDo.getUserGrayContactsRelationDistribution();//联系人的分布
			JSONObject user_graydisJson =JSONObject.parseObject(user_gray_contacts_relation_distribution);
			String graydis1=String.valueOf(user_graydisJson.get("to_is_familiar"));//主动联系的亲密联系人数（w>67)
			String graydis2=String.valueOf(user_graydisJson.get("to_median_familiar"));//主动联系的中等亲密联系人数（67>=w>=33)
			String graydis3=String.valueOf(user_graydisJson.get("to_not_familiar"));//主动联系的非亲密联系人数(w<33)
			String graydis4=String.valueOf(user_graydisJson.get("be_is_familiar"));//被动联系的亲密联系人数（w>67)
			String graydis5=String.valueOf(user_graydisJson.get("be_median_familiar"));//被动联系的中等亲密联系人数（67>=w>=33)
			String graydis6=String.valueOf(user_graydisJson.get("be_not_familiar"));//被动联系的非亲密联系人数(w<33)
			String graydis7=String.valueOf(user_graydisJson.get("is_familiar"));//互动联系的亲密联系人数（w>133)
			String graydis8=String.valueOf(user_graydisJson.get("median_familiar"));//互动联系的中等亲密联系人数（133>=w>=67)
			String graydis9=String.valueOf(user_graydisJson.get("not_familiar"));//互动联系的非亲密联系人数(w<67)
			model.addAttribute("graydis1",graydis1);model.addAttribute("graydis2",graydis2);
			model.addAttribute("graydis3",graydis3);model.addAttribute("graydis4",graydis4);
			model.addAttribute("graydis5",graydis5);model.addAttribute("graydis6",graydis6);
			model.addAttribute("graydis7",graydis7);model.addAttribute("graydis8",graydis8);
			model.addAttribute("graydis9",graydis9);
			
			//=========================================================================================
			String user_gray_contacts_query=reportDo.getUserGrayContactsQuery();//联系人查询历史
			JSONObject user_grayqueryJson =JSONObject.parseObject(user_gray_contacts_query);
			String grayQuery1=String.valueOf(user_grayqueryJson.get("to_recent_query_time"));//前半年内主动联系的人的最近一次查询时间
			Date dateQuery1=null;
			if(!StringUtils.isEmpty(grayQuery1) && grayQuery1!="null"){
				dateQuery1 = new Date(Long.parseLong(grayQuery1));
				grayQuery1=sdf.format(dateQuery1);
			}
			
			String grayQuery2=String.valueOf(user_grayqueryJson.get("be_recent_query_time"));//前半年内被动联系的人的最近一次查询时间
			Date dateQuery2=null;
			if(StringUtils.isEmpty(grayQuery2) && grayQuery2!="null"){
				dateQuery2 = new Date(Long.parseLong(grayQuery2));
				grayQuery2=sdf.format(dateQuery2);
			}
			String grayQuery3=String.valueOf(user_grayqueryJson.get("to_query_cnt_05"));//前半月内主动联系的人的查询次数
			String grayQuery4=String.valueOf(user_grayqueryJson.get("be_query_cnt_05"));//前半月内被动联系的人的查询次数
			String grayQuery5=String.valueOf(user_grayqueryJson.get("query_cnt_05"));//前半月内联系人的查询次数
			String grayQuery6=String.valueOf(user_grayqueryJson.get("to_query_cnt_1"));//前1月内主动联系的人的查询次数
			String grayQuery7=String.valueOf(user_grayqueryJson.get("be_query_cnt_1"));//前1月内被动联系的人的查询次数
			String grayQuery8=String.valueOf(user_grayqueryJson.get("query_cnt_1"));//前1月内联系人的查询次数
			String grayQuery9=String.valueOf(user_grayqueryJson.get("to_query_cnt_2"));//前2月内主动联系的人的查询次数
			String grayQuery10=String.valueOf(user_grayqueryJson.get("be_query_cnt_2"));//前2月内被动联系的人的查询次数
			String grayQuery11=String.valueOf(user_grayqueryJson.get("query_cnt_2"));//前2月内联系人的查询次数
			String grayQuery12=String.valueOf(user_grayqueryJson.get("to_query_cnt_3"));//前3月内主动联系的人的查询次数
			String grayQuery13=String.valueOf(user_grayqueryJson.get("be_query_cnt_3"));//前3月内被动联系的人的查询次数
			String grayQuery14=String.valueOf(user_grayqueryJson.get("query_cnt_3"));//前3月内联系人的查询次数
			String grayQuery15=String.valueOf(user_grayqueryJson.get("to_query_cnt_6"));//前6月内主动联系的人的查询次数
			String grayQuery16=String.valueOf(user_grayqueryJson.get("be_query_cnt_6"));//前6月内被动联系的人的查询次数
			String grayQuery17=String.valueOf(user_grayqueryJson.get("query_cnt_6"));//前6月内联系人的查询次数
			String grayQuery18=String.valueOf(user_grayqueryJson.get("to_query_cnt_9"));//前9月内主动联系的人的查询次数
			String grayQuery19=String.valueOf(user_grayqueryJson.get("be_query_cnt_9"));//前9月内被动联系的人的查询次数
			String grayQuery20=String.valueOf(user_grayqueryJson.get("query_cnt_9"));//前9月内联系人的查询次数
			String grayQuery21=String.valueOf(user_grayqueryJson.get("to_query_cnt_12"));//前12月内主动联系的人的查询次数
			String grayQuery22=String.valueOf(user_grayqueryJson.get("be_query_cnt_12"));//前12月内被动联系的人的查询次数
			String grayQuery23=String.valueOf(user_grayqueryJson.get("query_cnt_12"));//前12月内联系人的查询次数
			String grayQuery24=String.valueOf(user_grayqueryJson.get("to_org_cnt_05"));//前半月内主动联系的人的查询机构数
			String grayQuery25=String.valueOf(user_grayqueryJson.get("be_org_cnt_05"));//前半月内被动联系的人的查询机构数
			String grayQuery26=String.valueOf(user_grayqueryJson.get("org_cnt_05"));//前半月内联系人的查询机构数
			String grayQuery27=String.valueOf(user_grayqueryJson.get("to_org_cnt_1"));//前1月内主动联系的人的查询机构数
			String grayQuery28=String.valueOf(user_grayqueryJson.get("be_org_cnt_1"));//前1月内被动联系的人的查询机构数
			String grayQuery29=String.valueOf(user_grayqueryJson.get("org_cnt_1"));//前1月内联系人的查询机构数
			String grayQuery30=String.valueOf(user_grayqueryJson.get("to_org_cnt_2"));//前2月内主动联系的人的查询机构数
			String grayQuery31=String.valueOf(user_grayqueryJson.get("be_org_cnt_2"));//前2月内被动联系的人的查询机构数
			String grayQuery32=String.valueOf(user_grayqueryJson.get("org_cnt_2"));//前2月内联系人的查询机构数
			String grayQuery33=String.valueOf(user_grayqueryJson.get("to_org_cnt_3"));//前3月内主动联系的人的查询机构数
			String grayQuery34=String.valueOf(user_grayqueryJson.get("be_org_cnt_3"));//前3月内被动联系的人的查询机构数
			String grayQuery35=String.valueOf(user_grayqueryJson.get("org_cnt_3"));//前3月内联系人的查询机构数
			String grayQuery36=String.valueOf(user_grayqueryJson.get("to_org_cnt_6"));//前6月内主动联系的人的查询机构数
			String grayQuery37=String.valueOf(user_grayqueryJson.get("be_org_cnt_6"));//前6月内被动联系的人的查询机构数
			String grayQuery38=String.valueOf(user_grayqueryJson.get("org_cnt_6"));//前6月内联系人的查询机构数
			String grayQuery39=String.valueOf(user_grayqueryJson.get("to_org_cnt_9"));//前9月内主动联系的人的查询机构数
			String grayQuery40=String.valueOf(user_grayqueryJson.get("be_org_cnt_9"));//前9月内被动联系的人的查询机构数
			String grayQuery41=String.valueOf(user_grayqueryJson.get("org_cnt_9"));//前9月内联系人的查询机构数
			String grayQuery42=String.valueOf(user_grayqueryJson.get("to_org_cnt_12"));//前12月内主动联系的人的查询机构数
			String grayQuery43=String.valueOf(user_grayqueryJson.get("be_org_cnt_12"));//前12月内被动联系的人的查询机构数
			String grayQuery44=String.valueOf(user_grayqueryJson.get("org_cnt_12"));//前12月内联系人的查询机构数
			model.addAttribute("grayQuery1",grayQuery1);model.addAttribute("grayQuery2",grayQuery2);
			model.addAttribute("grayQuery3",grayQuery3);model.addAttribute("grayQuery4",grayQuery4);
			model.addAttribute("grayQuery5",grayQuery5);model.addAttribute("grayQuery6",grayQuery6);
			model.addAttribute("grayQuery7",grayQuery7);model.addAttribute("grayQuery8",grayQuery8);
			model.addAttribute("grayQuery9",grayQuery9);model.addAttribute("grayQuery10",grayQuery10);
			model.addAttribute("grayQuery11",grayQuery11);model.addAttribute("grayQuery12",grayQuery12);
			model.addAttribute("grayQuery13",grayQuery13);model.addAttribute("grayQuery14",grayQuery14);
			model.addAttribute("grayQuery15",grayQuery15);model.addAttribute("grayQuery16",grayQuery16);
			model.addAttribute("grayQuery17",grayQuery17);model.addAttribute("grayQuery18",grayQuery18);
			model.addAttribute("grayQuery19",grayQuery19);model.addAttribute("grayQuery20",grayQuery20);
			model.addAttribute("grayQuery21",grayQuery21);model.addAttribute("grayQuery22",grayQuery22);
			model.addAttribute("grayQuery23",grayQuery23);model.addAttribute("grayQuery24",grayQuery24);
			model.addAttribute("grayQuery25",grayQuery25);model.addAttribute("grayQuery26",grayQuery26);
			model.addAttribute("grayQuery27",grayQuery27);model.addAttribute("grayQuery28",grayQuery28);
			model.addAttribute("grayQuery29",grayQuery29);model.addAttribute("grayQuery30",grayQuery30);
			model.addAttribute("grayQuery31",grayQuery31);model.addAttribute("grayQuery32",grayQuery32);
			model.addAttribute("grayQuery33",grayQuery33);model.addAttribute("grayQuery34",grayQuery34);
			model.addAttribute("grayQuery35",grayQuery35);model.addAttribute("grayQuery36",grayQuery36);
			model.addAttribute("grayQuery37",grayQuery37);model.addAttribute("grayQuery38",grayQuery38);
			model.addAttribute("grayQuery39",grayQuery39);model.addAttribute("grayQuery40",grayQuery40);
			model.addAttribute("grayQuery41",grayQuery41);model.addAttribute("grayQuery42",grayQuery42);
			model.addAttribute("grayQuery43",grayQuery43);model.addAttribute("grayQuery44",grayQuery44);
			//==============================================================
			String auth_org=reportDo.getAuthOrg();//授权查询账户
			String user_phone_suspicion=reportDo.getUserPhoneSuspicion();//用这个手机号绑定了其他身份
			JSONObject user_susJson =JSONObject.parseObject(user_phone_suspicion);
			String userSusList1=String.valueOf(user_susJson.get("phone_with_other_idcards"));//用这个手机号码绑定的其他身份证
			StringBuffer bufferSusList1=new StringBuffer();
			JSONArray SusListArrays1 = JSONArray.fromObject(userSusList1);
			for (int j = 0; j < SusListArrays1.size(); j++) {
				 net.sf.json.JSONObject info = SusListArrays1.getJSONObject(j);
				 String str3="【身份证:"+info.get("susp_idcard")+"-时间："+info.get("susp_updt")+"】<br/>";
				 bufferSusList1.append(str3);
			}
			model.addAttribute("bufferSusList1", bufferSusList1);
			//---
			String userSusList2=String.valueOf(user_susJson.get("phone_with_other_names"));//用这个手机号码绑定的其他姓名
			StringBuffer bufferSusList2=new StringBuffer();
			JSONArray SusListArrays2 = JSONArray.fromObject(userSusList2);
			for (int j = 0; j < SusListArrays2.size(); j++) {
				 net.sf.json.JSONObject info = SusListArrays2.getJSONObject(j);
				 String str3="【姓名:"+info.get("susp_name")+"-时间："+info.get("susp_updt")+"】<br/>";
				 bufferSusList2.append(str3);
			}
			model.addAttribute("bufferSusList2", bufferSusList2);
			//----
			String userSusList3=String.valueOf(user_susJson.get("phone_applied_in_orgs"));//电话号码在那些类型的机构中使用过
			StringBuffer bufferSusList3=new StringBuffer();
			JSONArray SusListArrays3 = JSONArray.fromObject(userSusList3);
			for (int j = 0; j < SusListArrays3.size(); j++) {
				 net.sf.json.JSONObject info = SusListArrays3.getJSONObject(j);
				 String str3="【机构所属分类:"+info.get("susp_org_type")+"-时间："+info.get("susp_updt")+"】<br/>";
				 bufferSusList3.append(str3);
			}
			model.addAttribute("bufferSusList3", bufferSusList3);

			//==================================================================
			String user_idcard_suspicion=reportDo.getUserIdcardSuspicion();//身份证号码存疑
			JSONObject user_IdJson =JSONObject.parseObject(user_idcard_suspicion);
			String userId1=String.valueOf(user_IdJson.get("idcard_with_other_names"));
			StringBuffer bufferUserId1=new StringBuffer();
			JSONArray userIdArrays1 = JSONArray.fromObject(userId1);
			for (int j = 0; j < userIdArrays1.size(); j++) {
				 net.sf.json.JSONObject info = userIdArrays1.getJSONObject(j);
				 String str3="【姓名:"+info.get("susp_name")+"-时间："+info.get("susp_updt")+"】<br/>";
				 bufferUserId1.append(str3);
			}
			model.addAttribute("bufferUserId1", bufferUserId1);
			//----
			String userId2=String.valueOf(user_IdJson.get("idcard_with_other_phones"));
			StringBuffer bufferUserId2=new StringBuffer();
			JSONArray userIdArrays2 = JSONArray.fromObject(userId2);
			for (int j = 0; j < userIdArrays2.size(); j++) {
				 net.sf.json.JSONObject info = userIdArrays2.getJSONObject(j);
				 String str3="【存疑号码:"+info.get("susp_phone")+"-该号码出现次数："+info.get("times")+"】<br/>";
				 bufferUserId2.append(str3);
			}
			model.addAttribute("bufferUserId2", bufferUserId2);
			//----
			String userId3=String.valueOf(user_IdJson.get("idcard_applied_in_orgs"));
			StringBuffer bufferUserId3=new StringBuffer();
			JSONArray userIdArrays3 = JSONArray.fromObject(userId3);
			for (int j = 0; j < userIdArrays3.size(); j++) {
				 net.sf.json.JSONObject info = userIdArrays3.getJSONObject(j);
				 String str3="【机构所属分类:"+info.get("susp_org_type")+"-时间："+info.get("susp_updt")+"】<br/>";
				 bufferUserId3.append(str3);
			}
			model.addAttribute("bufferUserId3", bufferUserId3);
			//========================================================================
			String user_searched_history_by_orgs=reportDo.getUserBatchSearchedHistoryByOrgs();//用户被机构查询历史
			StringBuffer bufferhistory=new StringBuffer();
			JSONArray historyArrays = JSONArray.fromObject(user_searched_history_by_orgs);
			for (int j = 0; j < historyArrays.size(); j++) {
				 net.sf.json.JSONObject info = historyArrays.getJSONObject(j);
				 String str3="【查询机构:"+info.get("searched_org")+"-时间："+info.get("searched_date")+"】<br/>";
				 bufferhistory.append(str3);
			}
			model.addAttribute("bufferhistory",bufferhistory);
			//==============================================================
			String user_batch_searched_history_by_orgs=reportDo.getUserBatchSearchedHistoryByOrgs();//用户被机构批量查询至此
			//=================================================================
			String user_searched_history_by_day=reportDo.getUserSearchedHistoryByDay();//历史查询记录
			JSONObject historyJson =JSONObject.parseObject(user_searched_history_by_day);
			//7天
			String day7=String.valueOf(historyJson.get("d_7"));
			RspJuxinliHistoryDayModel modelday7=getHistoryDay(day7,"7");
			model.addAttribute("day_"+modelday7.getNum()+"_1",modelday7.getCnt());
			model.addAttribute("day_"+modelday7.getNum()+"_2",modelday7.getCnt_cash());
			model.addAttribute("day_"+modelday7.getNum()+"_3",modelday7.getCnt_cc());
			model.addAttribute("day_"+modelday7.getNum()+"_4",modelday7.getCnt_cf());
			model.addAttribute("day_"+modelday7.getNum()+"_5",modelday7.getCnt_org());
			model.addAttribute("day_"+modelday7.getNum()+"_6",modelday7.getCnt_org_cash());
			model.addAttribute("day_"+modelday7.getNum()+"_7",modelday7.getCnt_org_cc());
			model.addAttribute("day_"+modelday7.getNum()+"_8",modelday7.getCnt_org_cf());
			model.addAttribute("day_"+modelday7.getNum()+"_9",modelday7.getPct_cnt_all());
			model.addAttribute("day_"+modelday7.getNum()+"_10",modelday7.getPct_cnt_cash());
			model.addAttribute("day_"+modelday7.getNum()+"_11",modelday7.getPct_cnt_cc());
			model.addAttribute("day_"+modelday7.getNum()+"_12",modelday7.getPct_cnt_cf());
			model.addAttribute("day_"+modelday7.getNum()+"_13",modelday7.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday7.getNum()+"_14",modelday7.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday7.getNum()+"_15",modelday7.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday7.getNum()+"_16",modelday7.getPct_cnt_org_cf());
			//15天
			String day15=String.valueOf(historyJson.get("d_15"));
			RspJuxinliHistoryDayModel modelday15=getHistoryDay(day15,"15");
			model.addAttribute("day_"+modelday15.getNum()+"_1",modelday15.getCnt());
			model.addAttribute("day_"+modelday15.getNum()+"_2",modelday15.getCnt_cash());
			model.addAttribute("day_"+modelday15.getNum()+"_3",modelday15.getCnt_cc());
			model.addAttribute("day_"+modelday15.getNum()+"_4",modelday15.getCnt_cf());
			model.addAttribute("day_"+modelday15.getNum()+"_5",modelday15.getCnt_org());
			model.addAttribute("day_"+modelday15.getNum()+"_6",modelday15.getCnt_org_cash());
			model.addAttribute("day_"+modelday15.getNum()+"_7",modelday15.getCnt_org_cc());
			model.addAttribute("day_"+modelday15.getNum()+"_8",modelday15.getCnt_org_cf());
			model.addAttribute("day_"+modelday15.getNum()+"_9",modelday15.getPct_cnt_all());
			model.addAttribute("day_"+modelday15.getNum()+"_10",modelday15.getPct_cnt_cash());
			model.addAttribute("day_"+modelday15.getNum()+"_11",modelday15.getPct_cnt_cc());
			model.addAttribute("day_"+modelday15.getNum()+"_12",modelday15.getPct_cnt_cf());
			model.addAttribute("day_"+modelday15.getNum()+"_13",modelday15.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday15.getNum()+"_14",modelday15.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday15.getNum()+"_15",modelday15.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday15.getNum()+"_16",modelday15.getPct_cnt_org_cf());
			//30天
			String day30=String.valueOf(historyJson.get("d_30"));
			RspJuxinliHistoryDayModel modelday30=getHistoryDay(day30,"30");
			model.addAttribute("day_"+modelday30.getNum()+"_1",modelday30.getCnt());
			model.addAttribute("day_"+modelday30.getNum()+"_2",modelday30.getCnt_cash());
			model.addAttribute("day_"+modelday30.getNum()+"_3",modelday30.getCnt_cc());
			model.addAttribute("day_"+modelday30.getNum()+"_4",modelday30.getCnt_cf());
			model.addAttribute("day_"+modelday30.getNum()+"_5",modelday30.getCnt_org());
			model.addAttribute("day_"+modelday30.getNum()+"_6",modelday30.getCnt_org_cash());
			model.addAttribute("day_"+modelday30.getNum()+"_7",modelday30.getCnt_org_cc());
			model.addAttribute("day_"+modelday30.getNum()+"_8",modelday30.getCnt_org_cf());
			model.addAttribute("day_"+modelday30.getNum()+"_9",modelday30.getPct_cnt_all());
			model.addAttribute("day_"+modelday30.getNum()+"_10",modelday30.getPct_cnt_cash());
			model.addAttribute("day_"+modelday30.getNum()+"_11",modelday30.getPct_cnt_cc());
			model.addAttribute("day_"+modelday30.getNum()+"_12",modelday30.getPct_cnt_cf());
			model.addAttribute("day_"+modelday30.getNum()+"_13",modelday30.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday30.getNum()+"_14",modelday30.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday30.getNum()+"_15",modelday30.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday30.getNum()+"_16",modelday30.getPct_cnt_org_cf());
			//60天
			String day60=String.valueOf(historyJson.get("d_60"));
			RspJuxinliHistoryDayModel modelday60=getHistoryDay(day60,"60");
			model.addAttribute("day_"+modelday60.getNum()+"_1",modelday60.getCnt());
			model.addAttribute("day_"+modelday60.getNum()+"_2",modelday60.getCnt_cash());
			model.addAttribute("day_"+modelday60.getNum()+"_3",modelday60.getCnt_cc());
			model.addAttribute("day_"+modelday60.getNum()+"_4",modelday60.getCnt_cf());
			model.addAttribute("day_"+modelday60.getNum()+"_5",modelday60.getCnt_org());
			model.addAttribute("day_"+modelday60.getNum()+"_6",modelday60.getCnt_org_cash());
			model.addAttribute("day_"+modelday60.getNum()+"_7",modelday60.getCnt_org_cc());
			model.addAttribute("day_"+modelday60.getNum()+"_8",modelday60.getCnt_org_cf());
			model.addAttribute("day_"+modelday60.getNum()+"_9",modelday60.getPct_cnt_all());
			model.addAttribute("day_"+modelday60.getNum()+"_10",modelday60.getPct_cnt_cash());
			model.addAttribute("day_"+modelday60.getNum()+"_11",modelday60.getPct_cnt_cc());
			model.addAttribute("day_"+modelday60.getNum()+"_12",modelday60.getPct_cnt_cf());
			model.addAttribute("day_"+modelday60.getNum()+"_13",modelday60.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday60.getNum()+"_14",modelday60.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday60.getNum()+"_15",modelday60.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday60.getNum()+"_16",modelday60.getPct_cnt_org_cf());
			//90天
			String day90=String.valueOf(historyJson.get("d_90"));
			RspJuxinliHistoryDayModel modelday90=getHistoryDay(day90,"90");
			model.addAttribute("day_"+modelday90.getNum()+"_1",modelday90.getCnt());
			model.addAttribute("day_"+modelday90.getNum()+"_2",modelday90.getCnt_cash());
			model.addAttribute("day_"+modelday90.getNum()+"_3",modelday90.getCnt_cc());
			model.addAttribute("day_"+modelday90.getNum()+"_4",modelday90.getCnt_cf());
			model.addAttribute("day_"+modelday90.getNum()+"_5",modelday90.getCnt_org());
			model.addAttribute("day_"+modelday90.getNum()+"_6",modelday90.getCnt_org_cash());
			model.addAttribute("day_"+modelday90.getNum()+"_7",modelday90.getCnt_org_cc());
			model.addAttribute("day_"+modelday90.getNum()+"_8",modelday90.getCnt_org_cf());
			model.addAttribute("day_"+modelday90.getNum()+"_9",modelday90.getPct_cnt_all());
			model.addAttribute("day_"+modelday90.getNum()+"_10",modelday90.getPct_cnt_cash());
			model.addAttribute("day_"+modelday90.getNum()+"_11",modelday90.getPct_cnt_cc());
			model.addAttribute("day_"+modelday90.getNum()+"_12",modelday90.getPct_cnt_cf());
			model.addAttribute("day_"+modelday90.getNum()+"_13",modelday90.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday90.getNum()+"_14",modelday90.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday90.getNum()+"_15",modelday90.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday90.getNum()+"_16",modelday90.getPct_cnt_org_cf());
			//120天
			String day120=String.valueOf(historyJson.get("m_4"));
			RspJuxinliHistoryDayModel modelday120=getHistoryDay(day120,"120");
			model.addAttribute("day_"+modelday120.getNum()+"_1",modelday120.getCnt());
			model.addAttribute("day_"+modelday120.getNum()+"_2",modelday120.getCnt_cash());
			model.addAttribute("day_"+modelday120.getNum()+"_3",modelday120.getCnt_cc());
			model.addAttribute("day_"+modelday120.getNum()+"_4",modelday120.getCnt_cf());
			model.addAttribute("day_"+modelday120.getNum()+"_5",modelday120.getCnt_org());
			model.addAttribute("day_"+modelday120.getNum()+"_6",modelday120.getCnt_org_cash());
			model.addAttribute("day_"+modelday120.getNum()+"_7",modelday120.getCnt_org_cc());
			model.addAttribute("day_"+modelday120.getNum()+"_8",modelday120.getCnt_org_cf());
			model.addAttribute("day_"+modelday120.getNum()+"_9",modelday120.getPct_cnt_all());
			model.addAttribute("day_"+modelday120.getNum()+"_10",modelday120.getPct_cnt_cash());
			model.addAttribute("day_"+modelday120.getNum()+"_11",modelday120.getPct_cnt_cc());
			model.addAttribute("day_"+modelday120.getNum()+"_12",modelday120.getPct_cnt_cf());
			model.addAttribute("day_"+modelday120.getNum()+"_13",modelday120.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday120.getNum()+"_14",modelday120.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday120.getNum()+"_15",modelday120.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday120.getNum()+"_16",modelday120.getPct_cnt_org_cf());
			//150天
			String day150=String.valueOf(historyJson.get("m_5"));
			RspJuxinliHistoryDayModel modelday150=getHistoryDay(day150,"150");
			model.addAttribute("day_"+modelday150.getNum()+"_1",modelday150.getCnt());
			model.addAttribute("day_"+modelday150.getNum()+"_2",modelday150.getCnt_cash());
			model.addAttribute("day_"+modelday150.getNum()+"_3",modelday150.getCnt_cc());
			model.addAttribute("day_"+modelday150.getNum()+"_4",modelday150.getCnt_cf());
			model.addAttribute("day_"+modelday150.getNum()+"_5",modelday150.getCnt_org());
			model.addAttribute("day_"+modelday150.getNum()+"_6",modelday150.getCnt_org_cash());
			model.addAttribute("day_"+modelday150.getNum()+"_7",modelday150.getCnt_org_cc());
			model.addAttribute("day_"+modelday150.getNum()+"_8",modelday150.getCnt_org_cf());
			model.addAttribute("day_"+modelday150.getNum()+"_9",modelday150.getPct_cnt_all());
			model.addAttribute("day_"+modelday150.getNum()+"_10",modelday150.getPct_cnt_cash());
			model.addAttribute("day_"+modelday150.getNum()+"_11",modelday150.getPct_cnt_cc());
			model.addAttribute("day_"+modelday150.getNum()+"_12",modelday150.getPct_cnt_cf());
			model.addAttribute("day_"+modelday150.getNum()+"_13",modelday150.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday150.getNum()+"_14",modelday150.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday150.getNum()+"_15",modelday150.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday150.getNum()+"_16",modelday150.getPct_cnt_org_cf());
			//180天
			String day180=String.valueOf(historyJson.get("m_6"));
			RspJuxinliHistoryDayModel modelday180=getHistoryDay(day180,"180");
			model.addAttribute("day_"+modelday180.getNum()+"_1",modelday180.getCnt());
			model.addAttribute("day_"+modelday180.getNum()+"_2",modelday180.getCnt_cash());
			model.addAttribute("day_"+modelday180.getNum()+"_3",modelday180.getCnt_cc());
			model.addAttribute("day_"+modelday180.getNum()+"_4",modelday180.getCnt_cf());
			model.addAttribute("day_"+modelday180.getNum()+"_5",modelday180.getCnt_org());
			model.addAttribute("day_"+modelday180.getNum()+"_6",modelday180.getCnt_org_cash());
			model.addAttribute("day_"+modelday180.getNum()+"_7",modelday180.getCnt_org_cc());
			model.addAttribute("day_"+modelday180.getNum()+"_8",modelday180.getCnt_org_cf());
			model.addAttribute("day_"+modelday180.getNum()+"_9",modelday180.getPct_cnt_all());
			model.addAttribute("day_"+modelday180.getNum()+"_10",modelday180.getPct_cnt_cash());
			model.addAttribute("day_"+modelday180.getNum()+"_11",modelday180.getPct_cnt_cc());
			model.addAttribute("day_"+modelday180.getNum()+"_12",modelday180.getPct_cnt_cf());
			model.addAttribute("day_"+modelday180.getNum()+"_13",modelday180.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday180.getNum()+"_14",modelday180.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday180.getNum()+"_15",modelday180.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday180.getNum()+"_16",modelday180.getPct_cnt_org_cf());
			//270天
			String day270=String.valueOf(historyJson.get("m_9"));
			RspJuxinliHistoryDayModel modelday270=getHistoryDay(day270,"270");
			model.addAttribute("day_"+modelday270.getNum()+"_1",modelday270.getCnt());
			model.addAttribute("day_"+modelday270.getNum()+"_2",modelday270.getCnt_cash());
			model.addAttribute("day_"+modelday270.getNum()+"_3",modelday270.getCnt_cc());
			model.addAttribute("day_"+modelday270.getNum()+"_4",modelday270.getCnt_cf());
			model.addAttribute("day_"+modelday270.getNum()+"_5",modelday270.getCnt_org());
			model.addAttribute("day_"+modelday270.getNum()+"_6",modelday270.getCnt_org_cash());
			model.addAttribute("day_"+modelday270.getNum()+"_7",modelday270.getCnt_org_cc());
			model.addAttribute("day_"+modelday270.getNum()+"_8",modelday270.getCnt_org_cf());
			model.addAttribute("day_"+modelday270.getNum()+"_9",modelday270.getPct_cnt_all());
			model.addAttribute("day_"+modelday270.getNum()+"_10",modelday270.getPct_cnt_cash());
			model.addAttribute("day_"+modelday270.getNum()+"_11",modelday270.getPct_cnt_cc());
			model.addAttribute("day_"+modelday270.getNum()+"_12",modelday270.getPct_cnt_cf());
			model.addAttribute("day_"+modelday270.getNum()+"_13",modelday270.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday270.getNum()+"_14",modelday270.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday270.getNum()+"_15",modelday270.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday270.getNum()+"_16",modelday270.getPct_cnt_org_cf());
			//360天
			String day360=String.valueOf(historyJson.get("m_12"));
			RspJuxinliHistoryDayModel modelday360=getHistoryDay(day360,"360");
			model.addAttribute("day_"+modelday360.getNum()+"_1",modelday360.getCnt());
			model.addAttribute("day_"+modelday360.getNum()+"_2",modelday360.getCnt_cash());
			model.addAttribute("day_"+modelday360.getNum()+"_3",modelday360.getCnt_cc());
			model.addAttribute("day_"+modelday360.getNum()+"_4",modelday360.getCnt_cf());
			model.addAttribute("day_"+modelday360.getNum()+"_5",modelday360.getCnt_org());
			model.addAttribute("day_"+modelday360.getNum()+"_6",modelday360.getCnt_org_cash());
			model.addAttribute("day_"+modelday360.getNum()+"_7",modelday360.getCnt_org_cc());
			model.addAttribute("day_"+modelday360.getNum()+"_8",modelday360.getCnt_org_cf());
			model.addAttribute("day_"+modelday360.getNum()+"_9",modelday360.getPct_cnt_all());
			model.addAttribute("day_"+modelday360.getNum()+"_10",modelday360.getPct_cnt_cash());
			model.addAttribute("day_"+modelday360.getNum()+"_11",modelday360.getPct_cnt_cc());
			model.addAttribute("day_"+modelday360.getNum()+"_12",modelday360.getPct_cnt_cf());
			model.addAttribute("day_"+modelday360.getNum()+"_13",modelday360.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday360.getNum()+"_14",modelday360.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday360.getNum()+"_15",modelday360.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday360.getNum()+"_16",modelday360.getPct_cnt_org_cf());
			//540天
			String day540=String.valueOf(historyJson.get("m_18"));
			RspJuxinliHistoryDayModel modelday540=getHistoryDay(day540,"540");
			model.addAttribute("day_"+modelday540.getNum()+"_1",modelday540.getCnt());
			model.addAttribute("day_"+modelday540.getNum()+"_2",modelday540.getCnt_cash());
			model.addAttribute("day_"+modelday540.getNum()+"_3",modelday540.getCnt_cc());
			model.addAttribute("day_"+modelday540.getNum()+"_4",modelday540.getCnt_cf());
			model.addAttribute("day_"+modelday540.getNum()+"_5",modelday540.getCnt_org());
			model.addAttribute("day_"+modelday540.getNum()+"_6",modelday540.getCnt_org_cash());
			model.addAttribute("day_"+modelday540.getNum()+"_7",modelday540.getCnt_org_cc());
			model.addAttribute("day_"+modelday540.getNum()+"_8",modelday540.getCnt_org_cf());
			model.addAttribute("day_"+modelday540.getNum()+"_9",modelday540.getPct_cnt_all());
			model.addAttribute("day_"+modelday540.getNum()+"_10",modelday540.getPct_cnt_cash());
			model.addAttribute("day_"+modelday540.getNum()+"_11",modelday540.getPct_cnt_cc());
			model.addAttribute("day_"+modelday540.getNum()+"_12",modelday540.getPct_cnt_cf());
			model.addAttribute("day_"+modelday540.getNum()+"_13",modelday540.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday540.getNum()+"_14",modelday540.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday540.getNum()+"_15",modelday540.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday540.getNum()+"_16",modelday540.getPct_cnt_org_cf());
			//720天
			String day720=String.valueOf(historyJson.get("m_24"));
			RspJuxinliHistoryDayModel modelday720=getHistoryDay(day720,"720");
			model.addAttribute("day_"+modelday720.getNum()+"_1",modelday720.getCnt());
			model.addAttribute("day_"+modelday720.getNum()+"_2",modelday720.getCnt_cash());
			model.addAttribute("day_"+modelday720.getNum()+"_3",modelday720.getCnt_cc());
			model.addAttribute("day_"+modelday720.getNum()+"_4",modelday720.getCnt_cf());
			model.addAttribute("day_"+modelday720.getNum()+"_5",modelday720.getCnt_org());
			model.addAttribute("day_"+modelday720.getNum()+"_6",modelday720.getCnt_org_cash());
			model.addAttribute("day_"+modelday720.getNum()+"_7",modelday720.getCnt_org_cc());
			model.addAttribute("day_"+modelday720.getNum()+"_8",modelday720.getCnt_org_cf());
			model.addAttribute("day_"+modelday720.getNum()+"_9",modelday720.getPct_cnt_all());
			model.addAttribute("day_"+modelday720.getNum()+"_10",modelday720.getPct_cnt_cash());
			model.addAttribute("day_"+modelday720.getNum()+"_11",modelday720.getPct_cnt_cc());
			model.addAttribute("day_"+modelday720.getNum()+"_12",modelday720.getPct_cnt_cf());
			model.addAttribute("day_"+modelday720.getNum()+"_13",modelday720.getPct_cnt_org_all());
			model.addAttribute("day_"+modelday720.getNum()+"_14",modelday720.getPct_cnt_org_cash());
			model.addAttribute("day_"+modelday720.getNum()+"_15",modelday720.getPct_cnt_org_cc());
			model.addAttribute("day_"+modelday720.getNum()+"_16",modelday720.getPct_cnt_org_cf());
		}

		if ("1".equals(request.getParameter("downType"))) {
			return "system/loanJuxinliReport/honeyJarDownLoad";
		}
	    return "system/loanJuxinliReport/honeyJar";
	}
	
	
	public RspJuxinliHistoryDayModel getHistoryDay(String day,String num){
		JSONObject historyDayJson =JSONObject.parseObject(day);
		String day_1=String.valueOf(historyDayJson.get("cnt"));//查询次数
		String day_2=String.valueOf(historyDayJson.get("cnt_cash"));//现金贷查询次数
		String day_3=String.valueOf(historyDayJson.get("cnt_cc"));//信用卡代还查询次数
		String day_4=String.valueOf(historyDayJson.get("cnt_cf"));//消费分期查询次数
		String day_5=String.valueOf(historyDayJson.get("cnt_org"));//查询机构数
		String day_6=String.valueOf(historyDayJson.get("cnt_org_cash"));//现金贷查询机构数
		String day_7=String.valueOf(historyDayJson.get("cnt_org_cc"));//信用卡代还查询机构数
		String day_8=String.valueOf(historyDayJson.get("cnt_org_cf"));//消费分期查询机构数
		String day_9=String.valueOf(historyDayJson.get("pct_cnt_all"));//查询次数在总体查询分布中的百分位
		String day_10=String.valueOf(historyDayJson.get("pct_cnt_cash"));//查询次数在现金贷查询分布中的百分位
		String day_11=String.valueOf(historyDayJson.get("pct_cnt_cc"));//查询次数在信用卡代还查询分布中的百分位
		String day_12=String.valueOf(historyDayJson.get("pct_cnt_cf"));//查询次数在消费分期查询分布中的百分位
		String day_13=String.valueOf(historyDayJson.get("pct_cnt_org_all"));//查询机构数在总体查询分布中的百分位
		String day_14=String.valueOf(historyDayJson.get("pct_cnt_org_cash"));//查询机构数在现金贷查询分布中的百分位
		String day_15=String.valueOf(historyDayJson.get("pct_cnt_org_cc"));//查询机构数在信用卡代还查询分布中的百分位
		String day_16=String.valueOf(historyDayJson.get("pct_cnt_org_cf"));//查询机构数在消费分期查询分布中的百分位
		RspJuxinliHistoryDayModel daymodel=new RspJuxinliHistoryDayModel();
		daymodel.setCnt(day_1);
		daymodel.setCnt_cash(day_2);
		daymodel.setCnt_cc(day_3);
		daymodel.setCnt_cf(day_4);
		daymodel.setCnt_org(day_5);
		daymodel.setCnt_org_cash(day_6);
		daymodel.setCnt_org_cc(day_7);
		daymodel.setCnt_org_cf(day_8);
		daymodel.setPct_cnt_all(day_9);
		daymodel.setPct_cnt_cash(day_10);
		daymodel.setPct_cnt_cc(day_11);
		daymodel.setPct_cnt_cf(day_12);
		daymodel.setPct_cnt_org_all(day_13);
		daymodel.setPct_cnt_org_cash(day_14);
		daymodel.setPct_cnt_org_cc(day_15);
		daymodel.setPct_cnt_org_cf(day_16);
		daymodel.setNum(num);
		return daymodel;
	}
	
	/**
	 * 保存
	 */
	@ResponseBody
	@PostMapping("/save")
	@RequiresPermissions("system:loanJuxinliReport:add")
	public R save( LoanJuxinliReportDO loanJuxinliReport){
		if(loanJuxinliReportService.save(loanJuxinliReport)>0){
			return R.ok();
		}
		return R.error();
	}
	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("system:loanJuxinliReport:edit")
	public R update( LoanJuxinliReportDO loanJuxinliReport){
		loanJuxinliReportService.update(loanJuxinliReport);
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/remove")
	@ResponseBody
	@RequiresPermissions("system:loanJuxinliReport:remove")
	public R remove( Long id){
		if(loanJuxinliReportService.remove(id)>0){
		return R.ok();
		}
		return R.error();
	}
	
	/**
	 * 删除
	 */
	@PostMapping( "/batchRemove")
	@ResponseBody
	@RequiresPermissions("system:loanJuxinliReport:batchRemove")
	public R remove(@RequestParam("ids[]") Long[] ids){
		loanJuxinliReportService.batchRemove(ids);
		return R.ok();
	}
	
}
